package com.glaivelee.firstRefactor;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.glaivelee.abstracts.chooseType;

public class chooseType_Links extends chooseType {
	public chooseType_Links(String srcValue) {
		super(srcValue);
		dataInit();
		filterUselessWords();
	}
	
	
	
	//Regex start
	public String exeRex(){
		 String[] patternArr = {"<a\\s{0,}([^>]+)>(?<linkContent>(.*?))</a>",
				 				 "<a\\s{0,}(href=\".*?\")[^>]+>(?<linkContent>(.*?))</a>"};
		 for(int j = 0 ; j < patternArr.length ; j++){
		 	String filterStr = "";
		 	Pattern pattern = Pattern.compile(patternArr[j]);
	        Matcher matcher = pattern.matcher(srcValue);
			while (matcher.find()) {
				String spaceStrClear = clearHtmlLabels2(matcher.group("linkContent"));
				filterStr += "<a " + matcher.group(1) + " target=\"_blank\">"+spaceStrClear+"</a><br><br>";
	        }
	        srcValue = filterStr;
		 }
		 return srcValue;
	}

}
